package com.kfm.am;

public enum GirlFriend {

    // 所有的实例化对象都被定义在了第一行
    ZYJ("张一健", 23), LGW("李国伟", 22);

    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    GirlFriend(String name, int age) {
        this.name = name;
        this.age = age;
    }
}


class test03 {

    public static void main(String[] args) {
//        System.out.println(GirlFriend.ZYJ.getAge());
//        System.out.println(GirlFriend.ZYJ.getName());
//        System.out.println(GirlFriend.ZYJ);
        GirlFriend zyj = GirlFriend.ZYJ;
        System.out.println(zyj.ordinal());
        GirlFriend lgw = GirlFriend.LGW;
        System.out.println(lgw.ordinal());
        // 将枚举中所有对象实例放到数组中values
        GirlFriend[] values = GirlFriend.values();
        for (int i = 0; i < values.length; i++) {
            GirlFriend gf = values[i];
            System.out.println(gf.getName());
            System.out.println(gf.getAge());
        }
        GirlFriend zyj1 = GirlFriend.valueOf("ZYJ");
        System.out.println(zyj1.getName());
        zyj1.setName("张艺健");
        System.out.println(zyj1.getName());
    }
}
